var e = getApp();

Page({
    data: {
        showSuccess: !1,
        showSelectBind: !1,
        crm_member_list: [],
        selectMember: {},
        selectRadio: null,
        cservice: null,
        mobile: null
    },
    onLoad: function(e) {
        this.getBindData();
        var t = wx.getStorageSync("yz_basic_info");
        this.setData({
            cservice: t.home.mailInfo.cservice,
            mobile: t.home.mailInfo.service_mobile
        });
    },
    getBindData: function() {
        var t = this, s = e.getNetAddresss("plugin.ys-system.frontend.member-info.search-user");
        e._postNetWork({
            url: s,
            data: {},
            success: function(e) {
                var s = e.data;
                if (1 == s.result) {
                    var n = s.data.list || [];
                    n.forEach(function(e) {
                        var t = e.toString();
                        e.Address = t.replace(/[0-9]/gi, "*");
                    }), t.setData({
                        crm_member_list: n
                    }), 0 == s.data.is_binding ? t.setData({
                        showSelectBind: !0
                    }) : s.data.list.length > 0 ? t.setData({
                        showSuccess: !0,
                        selectMember: n[0]
                    }) : t.clonePages();
                } else wx.showToast({
                    icon: "none",
                    title: s.msg,
                    duration: 1e3
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    bindCrm: function() {
        var t = this;
        if (null != this.data.selectRadio) if (this.data.crm_member_list[s] && this.data.crm_member_list[s].CrmID) {
            var s = Number(this.data.selectRadio);
            this.setData({
                selectMember: this.data.crm_member_list[s]
            });
            var n = e.getNetAddresss("plugin.ys-system.frontend.member-info.appoint-bind-user");
            e._postNetWork({
                url: n,
                data: {
                    ys_user_id: this.data.crm_member_list[s].CrmID
                },
                success: function(e) {
                    var s = e.data;
                    1 == s.result ? t.setData({
                        showSelectBind: !1,
                        showSuccess: !0
                    }) : wx.showToast({
                        icon: "none",
                        title: s.msg,
                        duration: 1e3
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        } else wx.showToast({
            icon: "none",
            title: "缺少账号标识",
            duration: 1e3
        }); else wx.showToast({
            icon: "none",
            title: "请选择其中一个账号",
            duration: 1e3
        });
    },
    onChange: function(e) {
        console.log(e.detail), this.setData({
            selectRadio: e.detail
        });
    },
    linkService: function() {
        wx.navigateTo({
            url: this.data.cservice,
            fail: function(t) {
                e.tips("客服路由出错");
            }
        });
    },
    callPhone: function() {
        wx.makePhoneCall({
            phoneNumber: this.data.mobile
        });
    },
    clonePages: function() {
        this.setData({
            showSuccess: !1
        }), wx.navigateBack({
            delta: 1
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            path: "/packageG/index/index"
        };
    }
});